/**
 * @author Zvonimir Fras <zvonimir@frasbros.com>
 */

#ifndef NEURON_H
#define NEURON_H

#include <QObject>

#include <cmath>

#include "synapse.h"

class Neuron : public QObject
{
   friend class NeuralNetwork;
   public:
      Neuron( QObject *parent = 0 );
      Neuron( const Neuron &neuron );
      Neuron &operator=( const Neuron &neuron );
      
      void addPredecessor( Neuron *p );
      void addSuccessor( Neuron *p );
      
      void directInput( float in );
      void indirectInput();
      float getOutput();
      
      void setOutputNeedsUpdate( bool need = true );
      
   private:
      QList< Synapse * > m_leftSynapses;
      QList< Synapse * > m_rightSynapses;
      
      float m_error;
      
      bool m_directInput;
      bool m_outputNeedsUpdate;
      float m_output;
      float m_directValue;
      
      float m_w0;
      float m_a;
      
      float m_net();
};

#endif // NEURON_H
